package com.spa.infrastructure.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.command.admin.MassageServiceAddCommand;
import com.spa.application.command.admin.MassageServiceEditCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.MassageListExportDTO;
import com.spa.application.dto.admin.MassageServiceDTO;
import com.spa.application.dto.admin.MassageServiceListDTO;
import com.spa.application.dto.admin.MassagistAdminListDTO;
import com.spa.application.dto.member.MemberServiceDTO;
import com.spa.application.dto.member.MemberServiceDetailsDTO;
import com.spa.application.dto.shop.ShopServiceDTO;
import com.spa.application.dto.shop.ShopServiceDetailsDTO;
import com.spa.application.query.admin.MassageServiceQuery;
import com.spa.application.query.member.MemberServiceQuery;
import com.spa.domain.entity.MassageServiceEntity;
import com.spa.domain.entity.Massagist;
import com.spa.infrastructure.enums.dict.massagist.MassagistTagEnum;
import com.spa.infrastructure.enums.dict.massagist.MassagistTypeEnum;
import com.spa.infrastructure.repository.condition.MassageServiceCondition;
import com.spa.infrastructure.repository.po.MassageServicePO;
import com.spa.infrastructure.repository.po.OrderDetailPO;
import com.spa.infrastructure.repository.po.OrderExtDetailPO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface MassageServiceMapperStruct {

    MassageServiceMapperStruct INSTANCE = Mappers.getMapper(MassageServiceMapperStruct.class);

    List<MassageServiceEntity> po2Entity4List(List<MassageServicePO> po);

    List<MassageServicePO> entity2Po4List(List<MassageServiceEntity> mass);

    MassageServicePO entity2Po4List(MassageServiceEntity mass);

    MassageServiceEntity po2Entity(MassageServicePO po);


    @Mapping(source = "serviceSex", target = "sex")
    @Mapping(source = "serviceRecommendations", target = "recommendations")
    @Mapping(source = "serviceDuration", target = "duration")
    @Mapping(source = "serviceHighlights", target = "highlights")
    @Mapping(source = "serviceHighlightsTar", target = "highlightsTar")
    @Mapping(source = "serviceImg", target = "img")
    @Mapping(source = "serviceCover", target = "cover")
    @Mapping(source = "serviceNote", target = "note")
    @Mapping(source = "serviceDeclaration", target = "declaration")
    @Mapping(source = "servicePrice", target = "price")
    @Mapping(source = "serviceDiscountPrice", target = "discountPrice")
    @Mapping(source = "serviceTargetGroup", target = "targetGroup")
    MassageServiceEntity po2Entity(OrderDetailPO po);

    @Mapping(source = "serviceSex", target = "sex")
    @Mapping(source = "serviceRecommendations", target = "recommendations")
    @Mapping(source = "serviceDuration", target = "duration")
    @Mapping(source = "serviceHighlights", target = "highlights")
    @Mapping(source = "serviceHighlightsTar", target = "highlightsTar")
    @Mapping(source = "serviceImg", target = "img")
    @Mapping(source = "serviceCover", target = "cover")
    @Mapping(source = "serviceNote", target = "note")
    @Mapping(source = "serviceDeclaration", target = "declaration")
    @Mapping(source = "servicePrice", target = "price")
    @Mapping(source = "serviceDiscountPrice", target = "discountPrice")
    @Mapping(source = "serviceTargetGroup", target = "targetGroup")
    MassageServiceEntity po2Entity(OrderExtDetailPO po);

    Page<MassageServiceEntity> po2Entity4Page(Page<MassageServicePO> po);

    PageResult<MemberServiceDTO> entity2MemberDto4Page(Page<MassageServiceEntity> entity);
    PageResult<MassageServiceListDTO> entity2MassageServiceListDto4Page(Page<MassageServiceEntity> entity);

    @Mapping(source = "recommendations", target = "recommend")
    MemberServiceDTO entity2MemberDto(MassageServiceEntity entity);
    MemberServiceDetailsDTO entity2MemberInfoDto(MassageServiceEntity entity);

    ShopServiceDetailsDTO entity2ShopInfoDto(MassageServiceEntity entity);
    MassageServiceDTO entity2MassageServiceDto(MassageServiceEntity entity);
    MassageServiceCondition query2Condition(MemberServiceQuery query);
    MassageServiceCondition query2Condition(MassageServiceQuery query);

    MassageServicePO command2Po(MassageServiceAddCommand command);

    List<MemberServiceDTO> entity2MemberDto4List(List<MassageServiceEntity> entity);
    MassageServicePO command2Po(MassageServiceEditCommand command);


    PageResult<MassagistAdminListDTO> entity2MassagistAdminListDTO4Page(Page<Massagist> entity);

    @Mapping(source = "type", target = "type", qualifiedByName = "tag2Enum")
    @Mapping(source = "tag", target = "tag", qualifiedByName = "type2Enum")
    MassagistAdminListDTO entity2MassagistAdminListDTO(Massagist entity);

    List<ShopServiceDTO> entity2ShopDto4List(List<MassageServiceEntity> entity);

    List<MassageServiceListDTO> entity2MassagistAdminListDTO4List(List<MassageServiceEntity> entity);

    List<MassageListExportDTO> entity2MassageListExportDTO(List<MassageServiceEntity> entities);

    @Named("tag2Enum")
    default MassagistTagEnum tag2Enum(int type) {
        return MassagistTagEnum.byCode(type);
    }

    @Named("type2Enum")
    default MassagistTypeEnum type2Enum(int type) {
        return MassagistTypeEnum.byCode(type);
    }

}
